<?php

/**
 * sfWidgetFormWysiwyg represents a FCKEditor widget.
 *
 * @package    SchelkinoBiz
 * @subpackage widget
 * @author     Delight
 */
class sfWidgetFormFCKEditor extends sfWidgetForm
{
  /**
   * @param  string $name        The element name
   * @param  string $value       The value displayed in this widget
   * @param  array  $attributes  An array of HTML attributes to be merged with the default HTML attributes
   * @param  array  $errors      An array of errors for the field
   *
   * @return string An HTML tag string
   *
   * @see sfWidgetForm
   */
  public function render($name, $value = null, $attributes = array(), $errors = array())
  {
    sfContext::getInstance()->getConfiguration()->loadHelpers( "JavascriptBase" );

    $id = $this->generateId($name);

    return $this->renderContentTag('textarea', self::escapeOnce($value), array_merge(array('name' => $name), $attributes)).
           javascript_tag( "var {$id} = new FCKeditor('{$name}'); {$id}.ReplaceTextarea();" );
  }
}
